    function shownavigate ()
    {
        if (pagecount<=1)
            return;
        var i=0;
        var navtable="";
        if (pagecount<=10)
        {
            for (i=1;i<=pagecount;i++)
            {
                if (i!=currentpage)
                	 navtable+="&nbsp;<a href='showallphotos.htm?page="+i+"'>"+i+"</a> ";
                   // navtable+="&nbsp;<a href='javascript:showresult("+i+")'>"+i+"</a> ";
                else
                    navtable+=""+i+" ";
            }
            document.getElementById("navigate").innerHTML=navtable;
            return;
        }
        if (pagecount>10)
        {
            if (currentpage>1)
                navtable+="&nbsp;<a href='showallphotos.htm?page=1'>first</a> ";
                //navtable+="&nbsp;<a href='javascript:showresult(1);'>first</a> ";
            if (currentpage>2)
                navtable+="&nbsp;<a href='showallphotos.htm?page="+(currentpage-1)+"'>pre</a> ";
                //navtable+="&nbsp;<a href='javascript:showresult("+(currentpage-1)+")'>pre</a> ";
            if (currentpage<6)
            {
                for(i=1;i<10;i++)
                {
                    if(i!=currentpage)
                        navtable+="&nbsp;<a href='showallphotos.htm?page="+i+"'>"+i+"</a>";
                        //navtable+="&nbsp;<a href='javascript:showresult("+i+")'>"+i+"</a>";
                    else
                        navtable+="&nbsp;"+i+" ";
                }
            }
            else
            {
                for(i=currentpage-4;i<=((currentpage+5)>pagecount?pagecount:(currentpage+5));i++)
                {
                    if(i!=currentpage)
                        navtable+="&nbsp;<a href='showallphotos.htm?page="+i+"'>"+i+"</a>";
                        //navtable+="&nbsp;<a href='javascript:showresult("+i+")'>"+i+"</a>";
                    else
                        navtable+="&nbsp;"+i+" ";
                }
            }
            if (currentpage<pagecount-1)
                navtable+="&nbsp;...";
            if (currentpage<pagecount)
                navtable+="&nbsp;<a href='showallphotos.htm?page="+(currentpage+1)+"'>next</a> ";
                //navtable+="&nbsp;<a href='javascript:showresult("+(currentpage+1)+");'>next</a> ";
            if (currentpage<pagecount)
                navtable+="&nbsp;<a href='showallphotos.htm?page="+pagecount+"'>last</a> ";
                //navtable+="&nbsp;<a href='javascript:showresult("+pagecount+")'>last</a> ";
        }
        document.getElementById("navigate").innerHTML=navtable;
    };
    function showresult (page){
    	var i=0;
        currentpage=page;
        shownavigate();
        for (i=0;i<10;i++)
        {
        	document.getElementById("div"+i+"").innerHTML="";
        }
    	for (i=0;i<10;i++)
    	{
    		var pc=0;
    		//pc=(page-1)*10+i;
    		pc=i;
    		if (pc<=resultcount)
    		{
    			var result="";
    			result=document.getElementById("template").innerHTML;
    			result=result.replace(new RegExp("photoid","gm"), photos[pc][0]);
    			result=result.replace(new RegExp("phototitle","gm"), photos[pc][1]);
    			result=result.replace(new RegExp("photodescription","gm"), photos[pc][2]);
    			result=result.replace(new RegExp("photolastviewed","gm"), photos[pc][3]);
    			result=result.replace(new RegExp("photouploaded","gm"), photos[pc][4]);
    			result=result.replace(new RegExp("photoviewed","gm"), photos[pc][5]);
    			result=result.replace(new RegExp("photouser","gm"), photos[pc][6]);
    			result=result.replace(new RegExp("photocompetition","gm"), photos[pc][7]);
    			result=result.replace(new RegExp("photopreviewid","gm"), photos[pc][8]);
    			result=result.replace(new RegExp("photovoted","gm"), photos[pc][9]);
//    			result+="<table><tr><td>";
//    			result+="<a href='photo_"+photos[pc][0]+".jpg' rel='lightbox' title='"+photos[(page-1)*10+i][1]+"'>";
//    			result+="<img src='preview_"+photos[pc][0]+".jpg'/></a>";
//    			result+="</td></tr><tr><td>";
//    			result+="Title:"+photos[pc][1]+"";
//    			result+="</td></tr><tr><td>";
//    			result+="Description"+photos[pc][2]+"";
//    			result+="</td></tr><tr><td>";
//    			result+="Viewed:"+photos[pc][5]+"";
//    			result+="</td></tr></table>";
    			document.getElementById("div"+i+"").innerHTML=result;
    		}
    		else
    		{
    			var r="";
    			document.getElementById("div"+i+"").innerHTML=r;
    		}
    	}
    };